<?php
/*
 * Webing - The SNS Blog
 *
 * Copyright (c) 2009 Webing. All rights reserved.
 *
 * This is Main file
 */
 /*$Id: main.php 117 2012-03-15 07:48:08Z chopins.xiao@gmail.com $*/
 

define('ROOT', dirname(__FILE__));
final class Main
{
    public $get;
    public $post;
    public $cooke;
    public $session;
    public $config;
    public function __construct()
    {
        $this->config = new init();
        $this->get = $this->config['requset']->set_get();
        
        $this->load_widget();
    }
    public function load_widget()
    {
        if(isset($this->get['w']))
        {
            $widget = trim($this->get['w']);
        }else{
            $widget = 'Home';
        }
        if($this->config['widget']->chkwidget($widget))
        {
            return $this->config['widget']->loadwidget($widget);
        }else{
           return $this->config['widget']->widget_not_exists($widget);
        }
    }

}

function __autoload($class)
{
    $file_lib = ROOT . 'app/lib/' . $class .'.php';
    $file_webing = ROOT . 'app/lib/' . $class . '.php';
    if(file_exists($file_lib))
    {
        require_once $file_lib;
    }elseif(file_exists($file_webing))
    {
        require_once $file_webing;
    }else{
        exit("The name is $class of class file that not exists");
    }
}
return new Main();
?>
